﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.SimpleFlow
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.SimpleFlow;

    public class MapForsfTypeStep : EntityMapping<sfTypeStep>
    {
        public MapForsfTypeStep()
        {
            Property(x => x.IsEnd, map =>
            {
            });

            Property(x => x.OrderFlag, map =>
            {
            });

            Property(x => x.StepName, map =>
            {
                map.Length(200);
            });

            ManyToOne(x => x.Type, map =>
            {
                map.Column("TypeID");
            });

            Bag(x => x.StepRoles, map =>
            {
                map.Table("ref_Step_to_Roles");
                map.Key(keyMapper => keyMapper.Column("RoleId"));
            }, act => act.ManyToMany(m => m.Column("StepId")));

            Bag(x => x.StepUsers, map =>
            {
                map.Table("ref_Step_to_Users");
                map.Key(keyMapper => keyMapper.Column("UserId"));
            }, act => act.ManyToMany(m => m.Column("StepId")));
        }
    }
}
